package lesson10;

import java.util.concurrent.locks.ReentrantLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;

public class Demo_1002 {
    public static void main(String[] args) {
        //一个非公平锁
        ReentrantLock lock=new ReentrantLock();
        //创建一个非公平锁
        ReentrantLock lock1=new ReentrantLock(true);
        try {
            lock.lock();
            System.out.println("666");
            throw new RuntimeException();
        }finally {
            //这里保证了锁一定会释放掉
            lock.unlock();
            System.out.println("锁已经释放");
        }




    }
}
